package com.mall.product.controller;

import com.mall.common.annotation.IngoreResponseAdvice;
import com.mall.entity.TbItmeSpec;
import com.mall.product.service.ItemSpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: W
 * @date: 2021/07/27/10:38
 * Other:
 */
@RestController
@RequestMapping("/itemSpec")
@CrossOrigin
public class ItemSpecController {

    @Autowired
    private ItemSpecService itemSpecService;

    /**
     * 根据商品id 查询具体规格商品
     */
    @GetMapping("/findItemSpecByGoodsId")
    public List<TbItmeSpec> findItemSpecByGoodsId(Long goodsId){
        return itemSpecService.findItemSpecByGoodsId(goodsId);
    }

    @GetMapping("/findById")
    @IngoreResponseAdvice
    public TbItmeSpec findById(@RequestParam("id") Long id) {
        return itemSpecService.findById(id);
    }

    @PutMapping("/update")
    @IngoreResponseAdvice
    void update(@RequestBody TbItmeSpec itemSpec){
        itemSpecService.update(itemSpec);
    }
}
